﻿using System.Diagnostics;

namespace BlogAPIUnitTest
{
    using System;
    using BlogsAPI;
    using BlogsAPI.Search;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// Проверим, возможности по залогиниванию
    /// </summary>
    [TestClass]
    public class SearchTest
    {
        //[Test(Description = "Поиск слов")]
        [TestMethod]
        public void BlogsYandex()
        {
            BlogsYandex by = new BlogsYandex();
            BlogPost [] oRes = by.SearchFor("123", DateTime.Now.AddDays(-1));
            Assert.IsTrue(oRes.Length > 0);
        }

        //[Test(Description = "Поиск постов со ссылкой")]
        [TestMethod]
        public void BlogsYandexLink()
        {
            BlogsYandex by = new BlogsYandex();
            BlogPost[] oRes = by.SearchFor(new Uri("http://t30p.ru"), DateTime.Now.AddDays(-10));
            Assert.IsTrue(oRes.Length > 0);
        }

        //[Test(Description = "Поиск слов")]
        [TestMethod]
        public void NewsYandex()
        {
            NewsYandex bg = new NewsYandex();
            BlogPost[] oRes = bg.SearchFor("Путин || Медведев", DateTime.Now.AddDays(-1));
            Assert.IsTrue(oRes.Length > 0);
        }

        //[Test(Description = "Поиск постов со ссылкой")]
        [TestMethod]
        public void BlogsGoogleLink()
        {
            BlogsGoogle bg = new BlogsGoogle();
            BlogPost[] oRes = bg.SearchFor(new Uri("http://yandex.ru"), DateTime.Now.AddDays(-10));
            Assert.IsTrue(oRes.Length > 0);
        }


        //[Test(Description = "Поиск слов")]
        [TestMethod]
        public void BlogsGoogle()
        {
            BlogsGoogle bg = new BlogsGoogle();
            BlogPost[] oRes = bg.SearchFor("123", DateTime.Now.AddDays(-1));
            Assert.IsTrue(oRes.Length > 0);
        }

        //[Test(Description = "Поиск слов в вебе")]
        [TestMethod]
        public void WebGoogle()
        {
            BlogsGoogle bg = new BlogsGoogle{searchType = "web"};

            BlogPost[] oRes = bg.SearchFor("test site:facebook.com", DateTime.Now.AddDays(-1));
            Assert.IsTrue(oRes.Length > 0);
        }

        //[Test(Description = "Поиск слов в Wordpress'e")]
        [TestMethod]
        public void WordPress()
        {
            Wordpress bg = new Wordpress();
            BlogPost[] oRes = bg.SearchFor("Путин OR Медведев", DateTime.Now.AddDays(-1));
            Assert.IsTrue(oRes.Length > 0);
        }

        //[Test(Description = "Поиск слов в Plazoo")]
        [TestMethod]
        public void Plazoo()
        {
            var bg = new Plazoo();
            BlogPost[] oRes = bg.SearchFor("Путин OR Медведев", DateTime.Now.AddDays(-1));
            Assert.IsTrue(oRes.Length > 0);
        }

        //[Test(Description = "Поиск слов в Twitter")]
        [TestMethod]
        public void Twitter()
        {
            var bg = new TwiSearch();
            BlogPost[] oRes = bg.SearchFor("Медведев", DateTime.Now.AddHours(-1));
            Assert.IsTrue(oRes.Length > 0);
        }


        //[Test(Description = "Поиск слов в Youtube")]
        [TestMethod]
        public void Youtube()
        {
            YoutubeSearch bg = new YoutubeSearch();
            BlogPost[] oRes = bg.SearchFor("topbot|t30p|topbloger", DateTime.Now.AddDays(-10));
            Assert.IsTrue(oRes.Length > 0);
        }

        //[Test(Description = "Поиск картинок в Гугле")]
        [TestMethod]
        public void Images()
        {
            var ig = new ImagesGoogle();
            BlogPost[] oRes = ig.SearchFor("Отвязная Калифорния Фильм", DateTime.Now.AddDays(-10));
            Assert.IsTrue(oRes.Length > 0);
            Debug.Write(oRes[0].Link);
        }

        //[Test(Description = "Поиск через GooglePlus API")]
        [TestMethod]
        public void GooglePlusAPI()
        {
            GooglePlus gp = new GooglePlus();
            BlogPost[] oRes = gp.SearchFor("о", null, "ru");
            Assert.IsTrue(oRes.Length > 0);
        }
    }
}
